{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from mpl_toolkits.mplot3d import Axes3D\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "df = pd.read_csv(\"dns.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Data Quality Report\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Count</th>\n",
       "      <th>Unique Values</th>\n",
       "      <th>Missing Values</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>ts</th>\n",
       "      <td>float64</td>\n",
       "      <td>47963</td>\n",
       "      <td>44339</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>uid</th>\n",
       "      <td>object</td>\n",
       "      <td>47963</td>\n",
       "      <td>17991</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>id.orig_h</th>\n",
       "      <td>object</td>\n",
       "      <td>47963</td>\n",
       "      <td>128</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>id.orig_p</th>\n",
       "      <td>int64</td>\n",
       "      <td>47963</td>\n",
       "      <td>1762</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>id.resp_h</th>\n",
       "      <td>object</td>\n",
       "      <td>47963</td>\n",
       "      <td>91</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>id.resp_p</th>\n",
       "      <td>int64</td>\n",
       "      <td>47963</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>proto</th>\n",
       "      <td>object</td>\n",
       "      <td>47963</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trans_id</th>\n",
       "      <td>int64</td>\n",
       "      <td>47963</td>\n",
       "      <td>18099</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>query</th>\n",
       "      <td>object</td>\n",
       "      <td>41744</td>\n",
       "      <td>15775</td>\n",
       "      <td>6219</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>qclass</th>\n",
       "      <td>float64</td>\n",
       "      <td>41744</td>\n",
       "      <td>1</td>\n",
       "      <td>6219</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>qclass_name</th>\n",
       "      <td>object</td>\n",
       "      <td>41744</td>\n",
       "      <td>1</td>\n",
       "      <td>6219</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>qtype</th>\n",
       "      <td>float64</td>\n",
       "      <td>41744</td>\n",
       "      <td>6</td>\n",
       "      <td>6219</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>qtype_name</th>\n",
       "      <td>object</td>\n",
       "      <td>41744</td>\n",
       "      <td>6</td>\n",
       "      <td>6219</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>rcode</th>\n",
       "      <td>float64</td>\n",
       "      <td>38183</td>\n",
       "      <td>4</td>\n",
       "      <td>9780</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>rcode_name</th>\n",
       "      <td>object</td>\n",
       "      <td>38183</td>\n",
       "      <td>4</td>\n",
       "      <td>9780</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>AA</th>\n",
       "      <td>object</td>\n",
       "      <td>47963</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TC</th>\n",
       "      <td>object</td>\n",
       "      <td>47963</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>RD</th>\n",
       "      <td>object</td>\n",
       "      <td>47963</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>RA</th>\n",
       "      <td>object</td>\n",
       "      <td>47963</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Z</th>\n",
       "      <td>int64</td>\n",
       "      <td>47963</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>answers</th>\n",
       "      <td>object</td>\n",
       "      <td>34738</td>\n",
       "      <td>19816</td>\n",
       "      <td>13225</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TTLs</th>\n",
       "      <td>object</td>\n",
       "      <td>34738</td>\n",
       "      <td>17591</td>\n",
       "      <td>13225</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>rejected</th>\n",
       "      <td>object</td>\n",
       "      <td>47963</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Data Type  Count Unique Values  Missing Values\n",
       "ts            float64  47963         44339               0\n",
       "uid            object  47963         17991               0\n",
       "id.orig_h      object  47963           128               0\n",
       "id.orig_p       int64  47963          1762               0\n",
       "id.resp_h      object  47963            91               0\n",
       "id.resp_p       int64  47963             1               0\n",
       "proto          object  47963             2               0\n",
       "trans_id        int64  47963         18099               0\n",
       "query          object  41744         15775            6219\n",
       "qclass        float64  41744             1            6219\n",
       "qclass_name    object  41744             1            6219\n",
       "qtype         float64  41744             6            6219\n",
       "qtype_name     object  41744             6            6219\n",
       "rcode         float64  38183             4            9780\n",
       "rcode_name     object  38183             4            9780\n",
       "AA             object  47963             2               0\n",
       "TC             object  47963             1               0\n",
       "RD             object  47963             2               0\n",
       "RA             object  47963             2               0\n",
       "Z               int64  47963             1               0\n",
       "answers        object  34738         19816           13225\n",
       "TTLs           object  34738         17591           13225\n",
       "rejected       object  47963             2               0"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#DataFrame with columns\n",
    "columns = pd.DataFrame(list(df.columns.values[1:]))\n",
    "\n",
    "#DataFrame with data types\n",
    "data_types = pd.DataFrame(df.dtypes, columns=['Data Type'])\n",
    "\n",
    "#DataFrame with Count\n",
    "data_count = pd.DataFrame(df.count(), columns=['Count'])\n",
    "\n",
    "#DataFrame with unique values\n",
    "unique_value_counts = pd.DataFrame(columns=['Unique Values'])\n",
    "for v in list(df.columns.values):\n",
    "    unique_value_counts.loc[v] = [df[v].nunique()]\n",
    "\n",
    "missing_data_counts = pd.DataFrame(df.isnull().sum(), columns=['Missing Values'])\n",
    "data_quality_report = data_types.join(data_count).join(unique_value_counts).join(missing_data_counts)\n",
    "print('Data Quality Report')\n",
    "data_quality_report"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
